<?php

/**
 * MVM_MALL 网上商店系统  通行接口
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-02-03 $
 * $Id: passport.inc.php  www.mvmmall.com$
 * ---------------------------------------------
*/

if(!defined('MVMMALL')) exit('Access Denied');
unset($list,$grade);
if ($login_class==2){
	$list = $db->get_one("SELECT f.*,ff.cart_sess,ff.cart_id FROM `{$tablepre}member_table` f  LEFT JOIN `{$tablepre}cart_table` ff ON ff.cart_id = f.member_id WHERE f.member_email = '$login_id' AND f.member_pass='$login_pass'");
}else {
	$list = $db->get_one("SELECT f.*,ff.cart_sess,ff.cart_id FROM `{$tablepre}member_table` f  LEFT JOIN `{$tablepre}cart_table` ff ON ff.cart_id = f.member_id WHERE f.member_id = '$login_id' AND f.member_pass='$login_pass'");
}

if ($list[member_id]) {
($mm_close==0 && $list[adminid]!=1) && move_page(dreferer());
$db->query("update `{$tablepre}member_table` SET member_login = member_login + 1 WHERE member_id = '$list[member_id]'");
empty($referer) && $referer = dreferer();
$db->query("INSERT INTO `{$tablepre}login_table` SET login_id = '$list[member_id]',login_ip = '$m_user_ip',login_referer = '$referer',register_date  = '$m_now_time'");
$_SESSION['user']['mvm_sess_uid']   = $list[uid];
$_SESSION['user']['mvm_sess_id']    = $list[member_id];
$_SESSION['user']['mvm_sess_name']  = $list[member_name];
$_SESSION['user']['mvm_sess_email'] = $list[member_email];
$_SESSION['user']['mvm_sess_point'] = $list[member_point];
$_SESSION['user']['mvm_sess_money'] = $list[member_money];
$_SESSION['user']['mvm_adminid']    = $list[adminid];
$_SESSION['user']['mvm_group_id']   = $list[member_class];
$grade = $db->get_one("SELECT group_id,rank_list,degree FROM `{$tablepre}grade_table` WHERE group_id='$list[member_class]'");
$_SESSION['user']['mvm_sess_rank']  = $grade[degree];
$_SESSION['user']['mvm_rank_list']  = $grade['rank_list'];

//会员整合插件
$result = $db->query("SELECT id,class_name,cfg FROM `{$tablepre}passport`");
while ($port = $db->fetch_array($result)){
	include_once 'include/passport/'. $port[class_name].'.class.php';
	$rowst = new  $port[class_name](unserialize($port[cfg]));
	$rowst->post_login($list);
}
//end

show_msg('login_succeed',dreferer());
exit;

}else {
	show_msg('member_login_fail');
	exit;
}
